import { Injectable } from '@nestjs/common';

interface User {
  _id: string;
  name: string;
  password: string;
  role: 'admin' | 'account';
}

@Injectable()
export class UserService {
  // 模拟数据库
  protected users: User[] = [];

  create(user: Omit<User, '_id'>) {
    const _id = Math.random().toString(36).slice(2, 10);
    this.users.push({ ...user, _id });
  }

  findById(_id: string) {
    return this.users.find((v) => v._id === _id);
  }
}
